using System;
using CodePlex.DnD4eCampaignManager.DnD4e.Interfaces;

namespace CodePlex.DnD4eCampaignManager.DnD4e
{
    public class Movement : IMovement, IEquatable<Movement>
    {
        public int MovementSpeed { get; set; }
        public string MovementSpeedOther { get; set; }
        public int MovementStealth { get; set; }

        public override bool Equals(object obj)
        {
            if ( ReferenceEquals(null, obj) )
            {
                return false;
            }
            if ( ReferenceEquals(this, obj) )
            {
                return true;
            }
            if ( obj.GetType() != typeof ( Movement ) )
            {
                return false;
            }
            return Equals((Movement) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = MovementSpeed;
                result = ( result * 397 ) ^ ( MovementSpeedOther != null ? MovementSpeedOther.GetHashCode() : 0 );
                result = ( result * 397 ) ^ MovementStealth;
                return result;
            }
        }

        public bool Equals(Movement other)
        {
            if ( ReferenceEquals(null, other) )
            {
                return false;
            }
            if ( ReferenceEquals(this, other) )
            {
                return true;
            }
            return other.MovementSpeed == MovementSpeed && Equals(other.MovementSpeedOther, MovementSpeedOther) &&
                   other.MovementStealth == MovementStealth;
        }

        public static bool operator ==(Movement left, Movement right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(Movement left, Movement right)
        {
            return !Equals(left, right);
        }
    }
}